<template>
  <span style="margin-left: 10px">
    <slot v-if="buttonStatus">
      <div>请放入需要控制的按钮请放入需要控制的按钮</div>
    </slot>
  </span>
</template>
<script>
export default {
  name: 'AuthButton',
  props: ['authName'],
  data() {
    return {
      userAuth: JSON.parse(window.sessionStorage.getItem('userAuth')),
      isAdmin: JSON.parse(window.sessionStorage.getItem('isAdmin'))
    }
  },
  computed: {
    buttonStatus: {
      cache: false,
      get: function() {
        if (this.isAdmin) {
          return true
        }
        const authButtons = this.userAuth['authInfo'][this.$route.meta.id]
        if (authButtons) {
          for (var i = 0; i < authButtons.length; i++) {
            if (this.authName === authButtons[i]) {
              return true
            }
          }
        }
        return false
      }
    }
  }
}
</script>

<style scoped>

</style>
